import 'package:flutter/material.dart';
import 'package:flutter_tech_shop/src/screens/cart_page.dart';
import 'package:flutter_tech_shop/src/screens/favourites_page.dart';
import 'package:flutter_tech_shop/src/screens/profile_page.dart';
import 'package:flutter_tech_shop/src/screens/setting_page.dart';
import 'package:flutter_tech_shop/src/screens/store_page.dart';
import '../shared/styles.dart';
import '../shared/colors.dart';
import '../shared/fryo_icons.dart';
import './product_page.dart';
import '../shared/Product.dart';
import '../shared/partials.dart';

class Dashboard extends StatefulWidget {
  final String pageTitle;

  Dashboard({Key? key, required this.pageTitle}) : super(key: key);

  @override
  _DashboardState createState() => _DashboardState();
}

class _DashboardState extends State<Dashboard> {
  int _selectedIndex = 0;

  @override
  Widget build(BuildContext context) {
    final _tabs = [
      const StorePage(),
      const CartPage(),
      const FavouritesPage(),
      const ProfilePage(),
      const SettingPage(),
    ];

    return Scaffold(
        backgroundColor: bgColor,
        body: _tabs[_selectedIndex],
        bottomNavigationBar: BottomNavigationBar(
          items: const <BottomNavigationBarItem>[
            BottomNavigationBarItem(
              icon: Icon(Fryo.shop),
              label: 'Store',
            ),
            BottomNavigationBarItem(
              icon: Icon(Fryo.cart),
              label: 'My Cart',
            ),
            BottomNavigationBarItem(
              icon: Icon(Fryo.heart_1),
              label: 'Favourites',
            ),
            BottomNavigationBarItem(
              icon: Icon(Fryo.user_1),
              label: 'Profile',
            ),
            BottomNavigationBarItem(
              icon: Icon(Fryo.cog_1),
              label: 'Settings',
            )
          ],
          currentIndex: _selectedIndex,
          type: BottomNavigationBarType.fixed,
          fixedColor: Colors.green[600],
          onTap: _onItemTapped,
        ));
  }

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }
}

